package com.github.fujianlian.klinechart.draw;

import android.graphics.Canvas;

import androidx.annotation.NonNull;

import com.github.fujianlian.klinechart.BaseKLineChartView;
import com.github.fujianlian.klinechart.base.IChartDraw;
import com.github.fujianlian.klinechart.entity.h.ICandle;

/**
 * reate by tao on{DATE}
 */
public abstract class BaseDraw<C, T> implements IChartDraw<T> {
    int type;
    protected Class<C> tClass;

    public BaseDraw(Class<C> tClass) {
        this.tClass = tClass;
    }

    @Override
    public int getType() {
        return type;
    }

    @Override
    public void setType(int type) {
        this.type = type;
    }

    @Override
    public void drawText(@NonNull Canvas canvas, @NonNull BaseKLineChartView view, int position, float x, float y) {
    }

    protected C getEntity(ICandle candle) {
        return candle.getEntity(tClass);
    }

    protected void getEntity(ICandle candle, EetityCall<C> call) {
        C entity = candle.getEntity(tClass);
        if (null != call && null != entity) {
            call.onEntity(entity);
        }
    }

    public interface EetityCall<C> {

        void onEntity(C entity);
    }
}
